package com.bporcv.code.ch01;

/**
 * 以创建Runnable接口实例的方式创建线程
 */
public class WelcomeApp1 {

    public static void main(String[] args) {
        // 创建线程
        Thread welcomeThread = new Thread(new WelcomeTask());
        // 启动线程
        welcomeThread.start();
        // 输出"当前线程"的线程名称
        System.out.printf("1.Welcome! I'm %s.%n",Thread.currentThread().getName());
    }
}


class WelcomeTask implements Runnable{

    @Override
    public void run() {
        System.out.printf("2.Welcome! I'm %s.%n",Thread.currentThread().getName());
    }
}